package com.isfto.controller;


import com.isfto.code.ResponseData;
import com.isfto.entity.R;
import com.isfto.entity.tablepojo.ABRS;
import com.isfto.entity.tablepojo.FlightChange;
import com.isfto.entity.tablepojo.PageBean;
import com.isfto.entity.tablepojo.UpdateTickets;
import com.isfto.service.AbrsService;
import com.isfto.service.FlightChangeOutService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/apply")
public class FlightChangeOutController extends BaseController {
    @Resource
    FlightChangeOutService flightChangeService;
    @Resource
    AbrsService abrsService;

    @PostMapping("/out")
    public R<Object> saveInfo(@RequestBody FlightChange flightChange) {
        int total= flightChangeService.saveInfo(flightChange);
        return R.success(null);
    }

    @PostMapping("/upout")
    public R afterInfoOut(@RequestBody FlightChange flightChange){
        FlightChange flightChange1 = flightChangeService.afterInfoOut(flightChange);
        return R.success(null);
    }

    @PostMapping("/returnout")
    public R changeAfterInfoOut(@RequestBody FlightChange flightChange){
        FlightChange flightChange1 = flightChangeService.changeAfterInfoOut(flightChange);
        return R.success(null);
    }

    @PutMapping("/outstatus")
    public R updateStauts(@RequestBody FlightChange flightChange) {
        int i = flightChangeService.updateStauts(flightChange);
        return R.success(null);
    }

    @GetMapping("/exceptionreasonout")
    public List<ABRS> abrsInfo() {
        List<ABRS> abrs = abrsService.abrsInfo();
        return abrs;
    }
    @GetMapping("/audittickets")
    public ResponseData<Object> auditor(Integer page, Integer pageSize, Integer status) {
        PageBean pageBean = flightChangeService.audittickets(page,pageSize,status);
        return returnObject( pageBean );

    }

    @PostMapping("/updateStatus")
    public  ResponseData<Boolean> updateStatus(@RequestBody UpdateTickets updateTickets ){
        Integer id = updateTickets.getId();
        Integer status = updateTickets.getStatus();
        Boolean b = flightChangeService.updatetickertsStauts( id,status );
        return returnBoolean( b );
    }

    /**
     * 添加变更信息
     */
    @PostMapping("/filghtchange")
    public ResponseData<Boolean> filghtchange(@RequestBody FlightChange flightChange){

        Boolean insert = flightChangeService.insert( flightChange );

        return returnBoolean( insert );
    }

}
